package com.nacos.config.instance;

import com.alibaba.nacos.api.NacosFactory;
import com.alibaba.nacos.api.config.ConfigService;
import com.alibaba.nacos.api.exception.NacosException;
import com.alibaba.nacos.api.naming.NamingService;

import java.io.IOException;
import java.util.Properties;

/**
 * @author chn
 * @version 1.0
 * @Feature: 获取健康活不健康的实例
 * @data 2024/9/12 16:03
 */
public class selectHealthOrIllHealth {
    public static void main(String[] args) throws NacosException, IOException {
        try {
            Properties properties = new Properties();
            properties.put("serverAddr", "localhost:8848");
            properties.put("username", "nacos");
            properties.put("password", "nacos");

            ConfigService configService = NacosFactory.createConfigService(properties);
            NamingService namingService = NacosFactory.createNamingService(properties);

            System.out.println(namingService.selectInstances("test1", true));
        } catch (NacosException e) {
            e.printStackTrace();
        }

    }
}
